package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.dto.ClothingRequestDTO;
import com.example.demo.mapper.entity.Clothing;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ClothingManageMapper extends BaseMapper<Clothing> {
    @Delete("<script>" +
            "DELETE FROM clothing" +
            " WHERE clothing_id IN" +
            " <foreach collection='list' index='index' open='(' separator=',' close=')' item='clothingList' >" +
            "   #{clothingList.clothingId}" +
            " </foreach>" +
            "</script>")
    void batchDeleteClothing(List<Clothing> clothingList);

    @Delete("<script>" +
            "DELETE FROM commodity" +
            " WHERE clothing_id IN" +
            " <foreach collection='list' index='index' open='(' separator=',' close=')' item='clothingList' >" +
            "   #{clothingList.clothingId}" +
            " </foreach>" +
            "</script>")
    void batchDeleteCommodityClothing(List<Clothing> clothingList);

    @Delete("DELETE FROM `commodity` WHERE clothing_id = #{clothingId}")
    int deleteCommodity(Clothing clothing);
}
